<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>

    <link rel="stylesheet" href="css/login.css">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/util.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script>
        window.onload = function () {
            let info = getQuery("info");
            if (info == "no"){
                $("info").innerHTML = "请先登录"
            }
        };

        //点击登录验证用户
        async function findByNameAndPwd() {
            var param = {
                username: $("username").value,
                pwd:$("pwd").value
            };

            let user = await ajaxGet("/user/findByNameAndPwd",param);
            if (user == "ok"){
                location.href = "/html/index.html";
            }else if (user == "no"){
                alert("登录失败,用户名或者密码有误")
            }
        }


    </script>

</head>
<body>
    <div id="indexDiv">
        <div id="navDiv">
            <a href="">首页</a>  |
            <a href="">登录</a>  |
            <a href="">注册</a>  |
            <a href="">退出</a>  |
            <a href="">管理</a>  |
            <a href="">风格</a>
        </div>

        <div id="loginDiv">
            <span>登陆</span><br>
        </div>
        <span id="info" style="color: red"></span>

        <div id="inputDiv">
            <span>用户名： </span>
            <input type="text" id="username"><br>
            <span>用户密码： </span>
            <input type="password" id="pwd">
        </div>

        <div id="buttonDiv">
            <input type="button" value="登录" onclick="findByNameAndPwd()">
            <input type="button" value="重置">
        </div>
    </div>
</body>
</html>